package com.bestcem.xm.common.core.sql;

import lombok.AccessLevel;
import lombok.NoArgsConstructor;

/**
 * @author ming.xue <ming.xue@idiaoyan.com>
 * @desc 动态条件常量
 * @date 2021-05-21
 */
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class ConditionConstant {
    /**
     * 联系人字段-扩展字段列表
     */
    public static final String FIELD_VAL_LIST = "field_val_list";

    /**
     * 扩展字段-扩展字段标识
     */
    public static final String FIELD_ID = "field_id";

    /**
     * 动态条件-详细信息
     */
    public static final String DETAIL = "detail";

    /**
     * 动态条件-详细信息-左边界
     */
    public static final String DETAIL_LEFT_OPEN = "left_open";

    /**
     * 动态条件-详细信息-右边界
     */
    public static final String DETAIL_RIGHT_OPEN = "right_open";

    /**
     * 标识
     */
    public static final String ID = "id";

    /**
     * 名称
     */
    public static final String NAME = "name";

    /**
     * 动态条件-值类型
     */
    public static final String TYPE = "type";
    /**
     * 动态条件-值
     */
    public static final String VALUE = "value";

    /**
     * 动态条件-操作符
     */
    public static final String OPERATOR = "operator";

    /**
     * 动态条件-过滤器
     */
    public static final String FILTERS = "filters";

    /**
     * 动态条件-类别
     */
    public static final String CATEGORY = "category";

    /**
     * 问卷项目标识
     * use <code>PROJECT_ID<code/> instead
     * @see #PROJECT_ID
     */
    @Deprecated
    public static final String SURVEY_ID = "survey_id";

    /**
     * 问卷项目标识
     */
    public static final String PROJECT_ID = "project_id";

    /**
     * 问卷项目名称
     */
    public static final String PROJECT_NAME = "project_name";

    /**
     * 动态条件标识
     */
    public static final String CONDITION_ID = "__condition_id__";

    /**
     * 问卷相关条件结果键值
     * conditionId:memberId
     */
    public static final String SURVEY_CONDITION_RESULT_KEY_TEMPLATE = "%s:%s";

    /**
     * 版本号
     */
    public static final String CONDITION_VERSION = "t_type";

    /**
     * 动态条件最大嵌套层级
     */
    public static final int MAX_LEVEL = 3;

    /**
     * 规则
     */
    public static final String RULE = "rule";

    /**
     * 信息类型
     */
    public static final String SOURCE = "source";

    /**
     * 字段值
     */
    public static final String FIELD_VAL_LIST_FIELD_VALUE = "field_val_list.field_value";

    /**
     * 标签标识
     */
    public static final String TAG_ID = "tag_id";

    /**
     * 标签
     */
    public static final String LABELS = "labels";

    /**
     * 标签标识
     */
    public static final String LABEL_ID = "label_id";

    /**
     * 标签标识列表
     */
    public static final String LABEL_IDS = "label_ids";

    /**
     * 标签-标签值
     */
    public static final String LABEL_MAP = "label_map";

    /**
     * 依赖项最大值
     */
    public static final int MAX_DEPENDENCY_ITEM_LENGTH = 200;

    /**
     * 门店标识列表
     */
    public static final String STORE_IDS = "store_ids";

    /**
     * 字段类型
     */
    public static final class FieldTypes {
        public static final String DATETIME = "datetime";
        public static final String NUMBER = "number";
        public static final String STRING = "string";
        public static final String SELECT = "select";
        public static final String LEVEL = "level";
        public static final String ADDRESS = "address";
        public static final String TAG = "tag";
        public static final String LABEL = "label";
        public static final String GROUP = "group";
        public static final String FIELD_VAL_LIST = "field_val_list";
    }

    /**
     * 操作符
     */
    public static final class Operators {
        public static final String GT = "$gt";
        public static final String LT = "$lt";
        public static final String GTE = "$gte";
        public static final String LTE = "$lte";
        public static final String EQ = "$eq";
        public static final String NE = "$ne";
        public static final String IN = "$in";
        public static final String NIN = "$nin";
        public static final String REGEX = "$regex";
        public static final String NREGEX = "$nregex";
        public static final String RANGE = "$range";
        public static final String EXISTS = "$exists";
        public static final String NEXISTS = "$nexists";
        public static final String INCLUDE = "$include";
        public static final String BELONG = "$belong";
        public static final String NBELONG = "$nbelong";
    }

    /**
     * 操作符
     */
    public static final class RuleOperators {
        public static final String AND = "$and";
        public static final String OR = "$or";
    }

    /**
     * 打标签条件的数据来源
     */
    public static final class Sources {
        /**
         * 基础信息
         */
        public static final String INFO = "info";

        /**
         * 项目
         */
        public static final String PROJECT = "project";

        /**
         * 标签
         */
        public static final String TAG = "tag";

        /**
         * 标签
         */
        public static final String LABEL = "label";

        /**
         * 计算信息
         */
        public static final String COMPUTES = "computes";

        /**
         * 问卷
         */
        public static final String SURVEY = "survey";

        /**
         * 问卷
         */
        public static final String GROUP = "group";
    }
}
